package com.qiuyuliantu.base.controller;

import java.util.List;
import javax.servlet.http.HttpServletResponse;

import com.qiuyuliantu.base.domain.QiuGoalsModel;
import com.qiuyuliantu.base.service.IQiuGoalsModelService;
import org.springframework.security.access.prepost.PreAuthorize;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.PutMapping;
import org.springframework.web.bind.annotation.DeleteMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
import com.qiuyuliantu.common.annotation.Log;
import com.qiuyuliantu.common.core.controller.BaseController;
import com.qiuyuliantu.common.core.domain.AjaxResult;
import com.qiuyuliantu.common.enums.BusinessType;
import com.qiuyuliantu.base.domain.QiuGoalsModel;
import com.qiuyuliantu.base.service.IQiuGoalsModelService;
import com.qiuyuliantu.common.utils.poi.ExcelUtil;
import com.qiuyuliantu.common.core.page.TableDataInfo;

/**
 * 目标模板Controller
 *
 * @author ruoyi
 * @date 2025-03-22
 */
@RestController
@RequestMapping("/system/model")
public class QiuGoalsModelController extends BaseController
{
    @Autowired
    private IQiuGoalsModelService qiuGoalsModelService;

    /**
     * 查询目标模板列表
     */
    @PreAuthorize("@ss.hasPermi('system:model:list')")
    @GetMapping("/list")
    public TableDataInfo list(QiuGoalsModel qiuGoalsModel)
    {
        startPage();
        List<QiuGoalsModel> list = qiuGoalsModelService.selectQiuGoalsModelList(qiuGoalsModel);
        return getDataTable(list);
    }

    /**
     * 导出目标模板列表
     */
    @PreAuthorize("@ss.hasPermi('system:model:export')")
    @Log(title = "目标模板", businessType = BusinessType.EXPORT)
    @PostMapping("/export")
    public void export(HttpServletResponse response, QiuGoalsModel qiuGoalsModel)
    {
        List<QiuGoalsModel> list = qiuGoalsModelService.selectQiuGoalsModelList(qiuGoalsModel);
        ExcelUtil<QiuGoalsModel> util = new ExcelUtil<QiuGoalsModel>(QiuGoalsModel.class);
        util.exportExcel(response, list, "目标模板数据");
    }

    /**
     * 获取目标模板详细信息
     */
    @PreAuthorize("@ss.hasPermi('system:model:query')")
    @GetMapping(value = "/{id}")
    public AjaxResult getInfo(@PathVariable("id") Long id)
    {
        return success(qiuGoalsModelService.selectQiuGoalsModelById(id));
    }

    /**
     * 新增目标模板
     */
    @PreAuthorize("@ss.hasPermi('system:model:add')")
    @Log(title = "目标模板", businessType = BusinessType.INSERT)
    @PostMapping
    public AjaxResult add(@RequestBody QiuGoalsModel qiuGoalsModel)
    {
        return toAjax(qiuGoalsModelService.insertQiuGoalsModel(qiuGoalsModel));
    }

    /**
     * 修改目标模板
     */
    @PreAuthorize("@ss.hasPermi('system:model:edit')")
    @Log(title = "目标模板", businessType = BusinessType.UPDATE)
    @PutMapping
    public AjaxResult edit(@RequestBody QiuGoalsModel qiuGoalsModel)
    {
        return toAjax(qiuGoalsModelService.updateQiuGoalsModel(qiuGoalsModel));
    }

    /**
     * 删除目标模板
     */
    @PreAuthorize("@ss.hasPermi('system:model:remove')")
    @Log(title = "目标模板", businessType = BusinessType.DELETE)
	@DeleteMapping("/{ids}")
    public AjaxResult remove(@PathVariable Long[] ids)
    {
        return toAjax(qiuGoalsModelService.deleteQiuGoalsModelByIds(ids));
    }
}
